

from django.urls.converters import register_converter

class YearConverter:
    regex = "(19|20)[0-9]{2}"

    def to_python(self, value):
        return int(value)

    def to_url(self, value):
        return str(value)

register_converter(YearConverter, "year")